import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:oktoast/oktoast.dart';
import '../personal/personal_page.dart';

/// 关于我们页面
class FeedbackPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _FeedbackeyPage();
  }
}

class _FeedbackeyPage extends State<FeedbackPage> {
  String _versionNare = "";

  Future<bool> _onWillPop() async {
    PersonalPageState.globalKeythere.currentState?.reloadData();
    return true; // 返回true表示允许返回，返回false表示阻止返回
  }

  @override
  void initState() {
    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarColor: Color(0xFFffffff),
      statusBarIconBrightness: Brightness.dark,
    ));

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: _onWillPop,
      child: Scaffold(
        backgroundColor: Color(0xFFfafafa),
        appBar: _buildTitleBar(context),
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.all(40.0), // 设置内边距
            // 将 Column 包裹在 Center 中
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center, // 垂直居中
              children: [
                Spacer(),
                Spacer(),
                // 本地图片 90x90
                Image.asset(
                  'assets/app_img/mailbox.png', // 替换为你的图片路径
                  width: 90,
                  height: 90,
                ),
                SizedBox(height: 10), // 间距 10
                Container(
                  // alignment: Alignment.center,
                  child: GestureDetector(
                    onTap: () {
                      // 复制到剪切板
                      Clipboard.setData(ClipboardData(text: "kf@smavlink.com"));
                      // 打印消息
                      showToast("已复制");
                    },
                    child: RichText(
                      textAlign: TextAlign.center,
                      text: TextSpan(
                        style: TextStyle(
                          fontSize: 16,
                          color: Colors.grey,
                        ),
                        children: [
                          TextSpan(
                            text: "您可发送邮件至",
                          ),
                          TextSpan(
                            text: "kf@smavlink.com",
                            style: TextStyle(
                              color: Colors.blue,
                              decoration: TextDecoration.underline,
                            ),
                          ),
                          TextSpan(
                            text: ",感谢您的反馈!",
                          ),
                        ],
                      ),
                    ),
                  ),
                ),

                Spacer(),
                Spacer(),
                Spacer(),
              ],
            ),
          ),
        ),
      ),
    );
  }

  AppBar _buildTitleBar(BuildContext context) {
    return AppBar(
      toolbarHeight: 60,
      leading: IconButton(
        icon: Icon(Icons.arrow_back_ios), // 使用没有横线的返回箭头图标
        onPressed: () {
          _onWillPop();
          // 返回操作
          Navigator.of(context).pop();
        },
      ),
      backgroundColor: Color(0xFFffffff),
      automaticallyImplyLeading: false,
      // 禁用自动生成的返回按钮
      title: Text(
        "帮助与反馈",
        style: TextStyle(
          fontSize: 17,
          fontFamily: "PingFang SC",
          fontWeight: FontWeight.w600,
        ),
      ),
      centerTitle: true,
    );
  }

// 账户安全

// 其他
}
